namespace TuanHA_Combat_Routine
{
    using Styx.WoWInternals;
    using Styx.WoWInternals.WoWObjects;
    using System;
    using System.Collections.Generic;
    using System.Globalization;
    using System.Linq;

    internal class CombatLogEventArgs : LuaEventArgs
    {
        public CombatLogEventArgs(string eventName, uint fireTimeStamp, object[] args) : base(eventName, fireTimeStamp, args)
        {
        }

        public int DestFlags
        {
            get
            {
                return (int) ((double) base.Args[9]);
            }
        }

        public ulong DestGuid
        {
            get
            {
                return ulong.Parse(base.Args[7].ToString().Replace("0x", string.Empty), NumberStyles.HexNumber);
            }
        }

        public string DestName
        {
            get
            {
                return base.Args[8].ToString();
            }
        }

        public WoWUnit DestUnit
        {
            get
            {
                return ObjectManager.GetObjectsOfType<WoWUnit>(true, true).FirstOrDefault<WoWUnit>(delegate (WoWUnit o) {
                    if (!o.IsValid)
                    {
                        return false;
                    }
                    if (o.Guid != this.DestGuid)
                    {
                        return (o.DescriptorGuid == this.DestGuid);
                    }
                    return true;
                });
            }
        }

        public string Event
        {
            get
            {
                return base.Args[1].ToString();
            }
        }

        public string HideCaster
        {
            get
            {
                return base.Args[2].ToString();
            }
        }

        public int SourceFlags
        {
            get
            {
                return (int) ((double) base.Args[5]);
            }
        }

        public ulong SourceGuid
        {
            get
            {
                return ulong.Parse(base.Args[3].ToString().Replace("0x", string.Empty), NumberStyles.HexNumber);
            }
        }

        public string SourceName
        {
            get
            {
                return base.Args[4].ToString();
            }
        }

        public WoWUnit SourceUnit
        {
            get
            {
                return ObjectManager.GetObjectsOfType<WoWUnit>(true, true).FirstOrDefault<WoWUnit>(delegate (WoWUnit o) {
                    if (!o.IsValid)
                    {
                        return false;
                    }
                    if (o.Guid != this.SourceGuid)
                    {
                        return (o.DescriptorGuid == this.SourceGuid);
                    }
                    return true;
                });
            }
        }

        public WoWSpell Spell
        {
            get
            {
                return WoWSpell.FromId(this.SpellId);
            }
        }

        public int SpellId
        {
            get
            {
                return (int) ((double) base.Args[11]);
            }
        }

        public string SpellName
        {
            get
            {
                return base.Args[12].ToString();
            }
        }

        public WoWSpellSchool SpellSchool
        {
            get
            {
                return (WoWSpellSchool) ((int) ((double) base.Args[13]));
            }
        }

        public object[] SuffixParams
        {
            get
            {
                List<object> list = new List<object>();
                for (int i = 11; i < base.Args.Length; i++)
                {
                    if (base.Args[i] != null)
                    {
                        list.Add(list[i]);
                    }
                }
                return list.ToArray();
            }
        }

        public double Timestamp
        {
            get
            {
                return (double) base.Args[0];
            }
        }
    }
}

